
/**
 * AppleIIGo
 * Apple Clock class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "AppleClock.h"

AppleClock::AppleClock(Motherboard * motherboard, char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void AppleClock::onMemoryRequested() {
	romMemoryOffset =
		motherboard->getMemory()->requestMemory(APPLECLOCK_ROM_BYTENUM);
}

void AppleClock::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Mountain Computer Apple Clock ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
											  APPLECLOCK_ROM_BYTENUM,
											  romImage);
}

void AppleClock::writeIo(UINT16 address, UINT8 value) {
}

UINT8 AppleClock::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 AppleClock::readMemory(UINT16 address) {
	if ((address & 0xf80) == 0xf80)
		return timingGenerator->readFloatingBus();
	else
		return romMemory[address & 0x3ff];
}
